package nodes.command;

import java.util.List;
import parser.ParserException;
import model.Model;
import model.Turtle;
import nodes.AbstractNode;
import nodes.ConstantNode;


/**
 * Moves the turtle forward
 */
public class ForwardC extends AbstractCommand
{
    public AbstractNode evaluate (List<AbstractNode> myArguments, Model model)
    {
        if (myArguments.size() != Integer.parseInt(resources.getString("forward")))
        {
            throw ParserException.BAD_ARGUMENTS;
        }

        int numOfPixelsMoved = 0;
        for (Turtle currentTurtle : model.getActiveTurtles())
        {
            numOfPixelsMoved +=currentTurtle.move(myArguments.get(0).evaluate().getValue());
        }

        return new ConstantNode(numOfPixelsMoved);
    }
}
